package com.it;

import com.it.dao.BookDao;
import com.it.service.BookService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class App2 {
    public static void main(String[] args) {
        // 1.创建IoC容器对象，加载spring核心配置文件
        ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");

        // 2.从IOC容器中获取Bean对象(bookDao对象)
        BookDao bookDao = (BookDao) ctx.getBean("bookDao");

        // 3.调用Bean对象(bookDao对象)的方法
        bookDao.save();

        System.out.println("-----");

        BookService bookService = (BookService) ctx.getBean("bookService");
        bookService.save();
    }
}
